const mongoose = require("mongoose");

// 连接数据库
mongoose.connect("mongodb://localhost/happy-chat", {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

const db = mongoose.connection;
db.on("error", (err) => {
  console.log("mongoose 连接失败");
});
db.once("open", function () {
  // we're connected!
  console.log("mongoose 连接成功");
});

module.exports = {
  User: mongoose.model("User", require("./user")),
};
